package com.ums.servicezuul;

import com.ums.servicezuul.route.CustomRouteLocator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.web.http.CookieHttpSessionStrategy;
import org.springframework.session.web.http.HttpSessionStrategy;

@Configuration
public class CustomZuulConfig {

    @Autowired
    ZuulProperties zuulProperties;

    @Autowired
    ServerProperties serverProperties;

    //@Autowired
    //JdbcTemplate jdbcTemplate;

    @Bean
    public CustomRouteLocator routeLocator(){
        CustomRouteLocator customRouteLocator = new CustomRouteLocator(
                this.serverProperties.getServletPrefix(), this.zuulProperties);
        //customRouteLocator.setJdbcTemplate(jdbcTemplate);
        return customRouteLocator;
    }

    @Bean
    public HttpSessionStrategy httpSessionStrategy() {
        System.out.println("CustomZuulConfig.httpSessionStrategy");
        //return new HeaderHttpSessionStrategy();
        return new CookieHttpSessionStrategy();
    }



}
